package com.example.Configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class Webconfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        WebMvcConfigurer.super.addCorsMappings(registry);
        //放行所有方法
        registry.addMapping("/**")
                .allowedOrigins("*")
                //是否发送cookie
                .allowCredentials(true)
                //放行哪些请求
                .allowedMethods("GET", "POST", "DELETE", "PUT")
                //放行哪些原始请求头部信息
                .allowedHeaders("*")
                .exposedHeaders("*")
                .maxAge(3600*60);
    }
}